/**
 * 党风党纪管理管理初始化
 */
var PartDiscipline = {
    id: "PartDisciplineTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
PartDiscipline.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
           {title: '主键', field: 'id', visible: false, align: 'center', valign: 'middle'},
           {title: '党风党纪名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
            {title: '所属分类', field: 'category', visible: true, align: 'center', valign: 'middle'},
            {title: '顺序', field: 'sort', visible: true, align: 'center', valign: 'middle',sortable: true},
            {title: '内容', field: 'content', visible: true, align: 'center', valign: 'middle'},
            {title: '创建时间', field: 'createtime', visible: true, align: 'center', valign: 'middle',sortable: true}
    ];
};

/**
 * 检查是否选中
 */
PartDiscipline.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        PartDiscipline.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加党风党纪管理
 */
PartDiscipline.openAddPartDiscipline = function () {
    var index = layer.open({
        type: 2,
        title: '添加党风党纪管理',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/partDiscipline/partDiscipline_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看党风党纪管理详情
 */
PartDiscipline.openPartDisciplineDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '党风党纪管理详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/partDiscipline/partDiscipline_update/' + PartDiscipline.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除党风党纪管理
 */
PartDiscipline.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/partDiscipline/delete", function (data) {
            Feng.success("删除成功!");
            PartDiscipline.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("partDisciplineId",this.seItem.id);
        ajax.start();
    }
};
/**
 * 查询党风党纪模块参数对象
 */
PartDiscipline.formParams = function () {
    var queryData = {};
    
    queryData['name'] = $("#name").val();
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    
    return queryData;
};
/**
 * 查询党风党纪管理列表
 */
PartDiscipline.search = function () {
    PartDiscipline.table.refresh({query: PartDiscipline.formParams()});
};
/**
 * 搜索重置
 */
PartDiscipline.resetSearch = function(){
	$("#name").val("");
	$("#beginTime").val("");
	$("#endTime").val("");
	
	PartDiscipline.search();
}
$(function () {
    var defaultColunms = PartDiscipline.initColumn();
    var table = new BSTable(PartDiscipline.id, "/partDiscipline/list", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(PartDiscipline.formParams());
    PartDiscipline.table = table.init();
});
